RAIS  3.2
C:/Projekte/RAIS/Specific Masks/ReportViewer.aspx.cs
Go to the documentation of this file.
00001 using System;
00002 using System.Data;
00003 using System.Configuration;
00004 using System.Collections;
00005 using System.Collections.Generic;
00006 using System.Web;
00007 using System.Web.Security;
00008 using System.Web.UI;
00009 using System.Web.UI.WebControls;
00010 using System.Web.UI.WebControls.WebParts;
00011 using System.Web.UI.HtmlControls;
00012 using Microsoft.Reporting.WebForms;
00013 
00014 using RAIS.ApplicationLogicLayer;
00015 using RAIS.Common.DynamicMaskManagement;
00016 //using RAIS.Common.TableManagement;
00017 using RAIS.UI.Common;
00018 using RAIS.Common.UserManagement;
00019 
00020 namespace RAIS.UI.SpecificMasks
00021 {
00025     public partial class TestReport : System.Web.UI.Page
00026     {
00027                 //*********************************************************************
00028                 #region Fields
00029 
00032                 DynamicMaskData dynamicMaskData;
00033                 #endregion
00034                 //*********************************************************************
00035                 #region Properties
00036 
00039                 protected int MaskID
00040                 {
00041                         get
00042                         {
00043                                 return (Request[Constants.MASK_ID_PARAMETER_NAME] == null)
00044                                         ? 0
00045                                         : int.Parse(Request[Constants.MASK_ID_PARAMETER_NAME]);
00046                         }
00047                 }
00051                 protected string ReportOrientation
00052                 {
00053                         get
00054                         {
00055                                 return (Request[Constants.PAGE_ORIENTATION_PARAMETER_NAME] == null)
00056                                         ? "Portrait"
00057                                         : Request[Constants.PAGE_ORIENTATION_PARAMETER_NAME];
00058                         }
00059                 }
00063                 protected Dictionary<int, string> FiltersValues
00064                 {
00065                         get
00066                         {
00067                                 if (this.Session[UI.Common.Constants.QUERIES_FILTERS_VALUES_TAG] == null)
00068                                         return null;
00069                                 else
00070                                         return (Dictionary<int, string>)this.Session[UI.Common.Constants.QUERIES_FILTERS_VALUES_TAG];
00071                         }
00072                 }
00076                 protected UserData CurrentUser
00077                 {
00078                         get { return (UserData)this.Session[UI.Common.Constants.CURRENT_USER_TAG]; }
00079                 }
00080                 #endregion Properties
00081                 //*********************************************************************
00082                 #region Event handlers
00083         protected void Page_PreLoad(object sender, EventArgs e)
00084         {
00085             RAIS.UI.Common.PageManagement.TrimTextBoxValues(this);
00086         }
00093                 protected void Page_Load(object sender, EventArgs e)
00094         {
00095                         this.Response.Cache.SetNoStore();
00096                         if (!this.IsPostBack)
00097                         {
00098                                 this.dynamicMaskData = ApplicationLogicLayer.DynamicMaskManagement.GetDynamicMaskData(
00099                                         this.MaskID, 0, 0, this.CurrentUser, false);
00100                                 RestoreFilterValuesFromSession();
00101                                 UI.Common.DynamicMaskManagement.GetDataSetForListMask(this.dynamicMaskData);
00102 
00103                                 this.ODSreport.TypeName = "RAIS.Common.DynamicMaskManagement.DynamicMaskData";
00104                                 this.ODSreport.SelectMethod = "GetDataSet";
00105 
00106                                 this.RVmain.LocalReport.EnableExternalImages = true;
00107                 this.RVmain.LocalReport.DisplayName = (string)Session["ReportName"];
00108 
00109                 string virtualDirectori = Server.HtmlEncode(Request.ApplicationPath) == "/" ? "" : Server.HtmlEncode(Request.ApplicationPath);
00110                 //qwerty.Text = HttpContext.Current.Request.Url.Scheme + "://" + HttpContext.Current.Request.Url.Host + virtualDirectori + "/";
00111                                 this.RVmain.LocalReport.LoadReportDefinition(
00112                                         ReportManagement.CreateReportDefinition(
00113                                                   this.dynamicMaskData
00114                                                 , this.Server.MapPath(string.Empty)
00115                         , HttpContext.Current.Request.Url.Scheme + "://" + HttpContext.Current.Request.Url.Host + virtualDirectori + "/"
00116                                                 , this.ReportOrientation
00117                         , (string)Session["CultureName"]
00118                         , (bool)Session["IsRightToLeft"]));
00119 
00120                                 this.RVmain.LocalReport.DataSources.Add(
00121                                         new ReportDataSource(ReportManagement.DataSetName, ODSreport.ID));
00122                         }
00123         }
00124 
00125                 protected void ODSreport_ObjectCreated(object sender, ObjectDataSourceEventArgs e)
00126                 {
00127                         e.ObjectInstance = this.dynamicMaskData;
00128                 }
00129                 #endregion Event handlers
00130                 //*********************************************************************
00131                 #region Private methods
00132                 protected void RestoreFilterValuesFromSession()
00133                 {
00134                         foreach (KeyValuePair<int, DynamicMaskFilterData> kvp in this.dynamicMaskData.FiltersData)
00135                         {
00136                                 DynamicMaskFilterData filterData = kvp.Value;
00137 
00138                                 if (this.FiltersValues != null
00139                                         && this.FiltersValues.ContainsKey(filterData.DynamicMaskFilter.ID))
00140                                 {
00141                                         if (filterData.DynamicMaskFilter.Type == DynamicMaskFilter.FilterType.DatesRage)
00142                                         {
00143                                                 string dates = this.FiltersValues[filterData.DynamicMaskFilter.ID];
00144                                                 string[] datesArray = 
00145                                                         dates.Split(new string[] {RAIS.Common.Constants.DATE_UNTIL_LABEL_TEXT}
00146                                                         , int.MaxValue
00147                                                         , StringSplitOptions.None);
00148                                                 filterData.DateFrom = DateTime.Parse(datesArray[0]);
00149                                                 filterData.DateUntil = DateTime.Parse(datesArray[1]);
00150                                         }
00151                                         else
00152                                         {
00153                                                 filterData.CurrentLookupValue = int.Parse(this.FiltersValues[filterData.DynamicMaskFilter.ID]);
00154                                         }
00155                                 }
00156                         }
00157                 }
00158                 #endregion Private methods
00159         }
00160 }